home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: Alpha / Whiteline Alpha.iso / progtool / c / nkcc / nkcc.txt < prev    next >
Encoding:
Text File  |  1994-09-22  |  32.0 KB  |  804 lines

  1.  
  2. Documentation of: package\nkcc.s
  3. Date of creation: Thursday  19.05.1994  12.10
  4.  
  5. ********************************************************************************
  6. *
  7. *  Project name : NORMALIZED KEY CODE CONVERTER (NKCC)
  8. *  Module name  : Main module
  9. *  Symbol prefix: nkc
  10. *
  11. *  Author       : Harald Siegmund (HS)
  12. *  Co-Authors   : -
  13. *  Write access : HS
  14. *
  15. *  Notes        : The symbol NKCGEM will have to be defined on the assembler's
  16. *                 command line when translating the source of NKCC. Set its
  17. *                 value to 1 if you like to create the complete version. A value
  18. *                 of 0 will supress inclusion of the GEM part, making NKCC a few
  19. *                 KBytes smaller. Some functions and the GEM parameter arrays
  20. *                 are not available then.
  21. *
  22. *                 Translate this source with the MadMac assembler:
  23. *                 mac -dNKCGEM=1 -onkcc.o nkcc.s
  24. *                 mac -dNKCGEM=0 -onkcc_tos.o nkcc.s
  25. *
  26. *-------------------------------------------------------------------------------
  27. *  NKCC was developed with Atari's MadMac assembler. It should be possible to
  28. *  adapt the source to different assemblers with minor effort. Here's an
  29. *  overview of all MadMac-specific assembly directives used in this source file:
  30. *
  31. *  .globl         declares a symbol to be imported from another module
  32. *                  respectively exported from the current source (depending if
  33. *                  the symbol is defined in the source or not)
  34. *  .if <expr>     conditional assembly; <expr> is tested to be non-zero (true)
  35. *                 or zero (false)
  36. *  .else
  37. *  .endif
  38. *  =              equate
  39. *  .abs           absolute section; is usually used to defined structure
  40. *                  offsets. Labels in the absolute section get a constant
  41. *                  value and usually have a .ds directive in their opcode
  42. *                  field incrementing the value for the next label
  43. *  .macro         introcudes a macro definition
  44. *  .endm          ends a macro definition
  45. *
  46. *  Macros:
  47. *   .macro name [argument,argument,...]
  48. *   Arguments accesses inside the macro must have a backslash character
  49. *    (e.g. move   \argument1,d0)
  50. *   The expression  \?{argument}  tests if an argument is defined or not.
  51. *
  52. *  Symbols:
  53. *   MadMac supports local symbols with a limited scope. Their name starts with
  54. *   a period (.) and their scope ends at the next global symbol (in both
  55. *   directions).
  56. *
  57. *-------------------------------------------------------------------------------
  58. *  Things to do :
  59. *
  60. *  -  NKCC will support additional (and more complex) deadkeys some time, such
  61. *     like Arabian ones. A communication interface between NKCC and a text
  62. *     editor will be built in for that purpose (Arabian languages' deadkeys can
  63. *     affect existing text!).
  64. *
  65. *-------------------------------------------------------------------------------
  66. *  History:
  67. *
  68. *  1989:
  69. *     May 14: creation of file (NKCC 1.00)
  70. *     Jun 07/15-16/19/21/Jul 11: improvements, changes, debugging
  71. *  1990:
  72. *     Jan 13: global functions now available in two versions:
  73. *             parameters passed via registers (e.g. for Turbo C)
  74. *             parameters passed via stack (underscore before label name)
  75. *
  76. *     May 23-24/26-28: creation of NKCC 2.00 (almost every function rewritten)
  77. *     Jun 16/27: assembler-entry added by Gerd Knops
  78. *     Jun 30/Jul 02: return shift key flags in nkc_multi()/amulti() as NKF?_...
  79. *     Jul 09: nkc_kstate()
  80. *     Aug 03: nkc_cmp()
  81. *     Aug 18: fatal bug in nkc_kstate() fixed
  82. *     Sep 15: nkc_timer()
  83. *     Sep 15-17/30: own button event handler
  84. *     Oct 03: debugging
  85. *             nkc_vlink()/vunlink()
  86. *             documentation syntax changed (LRef/XRef removed; Reg: changed)
  87. *     Oct 05: debugging mouse button handler (problems with menu bar)
  88. *     Oct 07: Control/Alternate + character always returns capital characters
  89. *             changing key code comparism rules in nkc_cmp()
  90. *     Oct 22: debugging nkc_cmp() (did sometimes recognize unique key codes)
  91. *             debugging ASCII code input in nkc_amulti()
  92. *     Dec 11/15/17: MU_XTIMER
  93. *  1991:
  94. *     Jan 11: don't call AES with set MU_XTIMER flag
  95. *     Mar 31: ensure that evnt_multi() parameters are restored when being
  96. *             corrupted by a bug in AES!!
  97. *     Apr 01: debugging
  98. *     Apr 13: nkc_conv() renamed to nkc_tconv()
  99. *     Apr 13-14: nkc_gconv()
  100. *     May 10: debugging (nk_beend())
  101. *     May 29: debugging (double shift key compare)
  102. *             export nkc_toupper and nkc_tolower
  103. *     Jul 05: completing history
  104. *     Jul 31: version number before XBRA header
  105. *     Aug 06: " is now a deadkey!
  106. *     Aug 07: more deadkeys...
  107. *     Aug 22: deadkeys can now be enabled/disabled separately
  108. *             nkc_set() changed
  109. *             nkc_init() returns version #
  110. *             bug fixed: nkc_cmp() corrupted high words of D3 and D4
  111. *     Sep 07/14: nkc_cmp() improved; NKF?_RESVD now in use
  112. *     Nov 05: adjustments to ASCII input feature of TOS 3.06
  113. *     Nov 16: bug fixed in nkc_cmp() mechanism
  114. *             Control key emulation
  115. *     Dec 29: small corrections and extensions of the documentation
  116. *             source documentation syntax now in extra file
  117. *  1992:
  118. *     Jan 03: changing documentation of nkc_init()
  119. *             revising info lines in function headers
  120. *     Jan 12: adjusting nkc_init() to its new documentation!
  121. *             appending .b respectively .l to all instructions with a default
  122. *              operand size which is not .w
  123. *             changing macro XBRA_HD
  124. *     Feb 11: adjusting button event handler to MINT
  125. *     Feb 28: NKCOWNPB switch
  126. *  1993:
  127. *     Dec 11: merging the two existing NKCC versions to one source:
  128. *             - version number set to $0290
  129. *             - NKCNOGEM/NKCOWNPB keys replaced by NKCGEM key
  130. *             - NKCC uses its own AES/VDI parameter arrays now
  131. *             - nkc_init() gets one more parameter: ^AES global array
  132. *             - nkc_toupper and nkc_tolower are functions now
  133. *             - dynamic double click time
  134. *             - MU_MESAG occured -> don't create self-made button events
  135. *     Dec 12: GEM keyboard events: try to get original shift flags from the
  136. *              Iorec buffer
  137. *             new functions: nkc_n2tos() and nkc_n2gem()
  138. *     Dec 13: debugging: ! operator changed to ~ in nk_bestart
  139. *             implementing nkc_n2tos()
  140. *             size of GEM parameter arrays changed to 32 (larger than required
  141. *              but better too big than too small!)
  142. *     Dec 16: debugging nkc_n2tos()
  143. *     Dec 19: improving nkc_gconv() (scan code translation table)
  144. *             debugging nkc_n2tos()
  145. *             cosmetic changes
  146. *     Dec 23: debugging nkc_vunlink(): return status was garbage!
  147. *  1994:
  148. *     May 19: release 2.91:
  149. *             don't restore conterm (it may be changed by another process in
  150. *              the meantime)
  151. *             new deadkeys (/2 /4)
  152. *             adding overview of used MadMac directives in the note section of
  153. *              the file header
  154. *
  155. ********************************************************************************
  156. *KEY _NAME="NKCC"
  157.  
  158.  
  159. ****************************************************************************
  160. *                         ASSEMBLER CONTROL SECTION                        *
  161. ****************************************************************************
  162.  
  163. *KEY &NKCGEM
  164. *     define this symbol on the assembler's command line
  165. *     =0    create TOS-version of NKCC (without GEM part)
  166. *     =1    create GEM-version of NKCC
  167.  
  168.                .include "nkcc.sh"            ; NKCC definitions
  169.  
  170.  
  171. ****************************************************************************
  172. *                                  EXPORT                                  *
  173. ****************************************************************************
  174.  
  175.                                              ; functions
  176.                .globl   nkc_init             ; init NKCC
  177.                .globl   nkc_exit             ; exit NKCC
  178.                .globl   nkc_set              ; set special key flags
  179.                .globl   nkc_conin            ; NKCC key input via GEMDOS
  180.                .globl   nkc_cstat            ; console input status via GEMDOS
  181.                .globl   nkc_tconv            ; TOS key code converter
  182.                .globl   nkc_gconv            ; GEM key code converter
  183.                .globl   nkc_n2tos            ; NKC to TOS key code converter
  184.                .globl   nkc_n2gem            ; NKC to GEM key code converter
  185.                .globl   nkc_kstate           ; return shift key state
  186.                .globl   nkc_timer            ; return 200 Hz system clock
  187.                .globl   nkc_cmp              ; compare two key codes
  188.                .globl   nkc_vlink            ; link function to XBRA vector list
  189.                .globl   nkc_vunlink          ; unlink function from XBRA list
  190.                .globl   nkc_toupper          ; convert character to upper case
  191.                .globl   nkc_tolower          ; convert character to lower case
  192.  
  193.                .if      NKCGEM=1
  194.  
  195.                 .globl  nkc_multi            ; NKCC multi event handler
  196.                 .globl  nkc_amulti           ; multi event, assembler binding
  197.                 .globl  nkc_contrl           ; GEM parameter arrays
  198.                 .globl  nkc_intin
  199.                 .globl  nkc_intout
  200.                 .globl  nkc_adrin
  201.                 .globl  nkc_adrout
  202.                 .globl  nkc_ptsin
  203.                 .globl  nkc_ptsout
  204.  
  205.                .endif   ; .if NKCGEM=1
  206.  
  207.  
  208. ****************************************************************************
  209. *                            GLOBAL TEXT SECTION                           *
  210. ****************************************************************************
  211.  
  212.  
  213. ****************************************************************************
  214. *
  215. *  nkc_init: initialize NKCC
  216. *  # G U
  217. *
  218. *  This function initializes NKCC. It must be called once before any other
  219. *  NKCC routine. It performs some tasks that may be important for you to
  220. *  know:
  221. *
  222. *  - bit 3 of the system variable <conterm> ($484.B) is set
  223. *  - a 200 Hz clock interrupt is installed, using the XBRA method (ID is
  224. *    "NKCC")
  225. *
  226. *  nkc_init() gets some flags which configure NKCC and enable some special
  227. *  functions:
  228. *
  229. *  NKI?_BUTHND       install NKCC's button event handler (see documentation
  230. *                    NKCC.DOC for details)
  231. *  NKI?_BHTOS        additional flag: install only, if TOS has mouse click bug
  232. *  NKI?_NO200HZ      don't install the 200 Hz timer interrupt
  233. *
  234. *  Notes:
  235. *
  236. *  - if NKCC is assembled as TOS-only version (symbol NKCGEM set to 0),
  237. *    both NKI?_BUTHND and NKI?_BHTOS flags are ignored.
  238. *
  239. *  - if the button event handler is installed, the NKI?_NO200HZ flag is
  240. *    ignored (because the 200 Hz clock is needed by the handler). Besides,
  241. *    the initialization continues:
  242. *
  243. *    - an own GEM trap handler (trap #2) is installed, using the XBRA method
  244. *      (to be up to date when a new double click time is set via the AES
  245. *      function evnt_dclick())
  246. *
  247. *    - a vex_butv() call (VDI) is made to install a mouse button exchange
  248. *      handler
  249. *
  250. *  In:   D0.L           miscellaneous flags (NKI?_...); see above
  251. *        D1.W           handle of an open VDI workstation
  252. *                       (must only be valid if the button handler is
  253. *                       installed)
  254. *        A0.L           ^applications GLOBAL array (from GEM parameter block)
  255. *                       not used in the TOS version of NKCC
  256. *
  257. *  Out:  D0.W           NKCC's version number as 4 digit BCD
  258. *                       (main # in high byte, sub # in low byte)
  259. *
  260. *  Reg:  D:01234567   A:01234567   CCR
  261. *          U**.....     **......    *
  262. *
  263. ****************************************************************************
  264.  
  265.  
  266. ****************************************************************************
  267. *
  268. *  nkc_exit: exit NKCC
  269. *  # G U
  270. *
  271. *  nkc_exit() must be called before the program is quit. It removes all
  272. *  handlers installed in the system.
  273. *
  274. *  In:   -
  275. *
  276. *  Out:  D0.W           status flag:
  277. *                       0     OK
  278. *                       -1    can't remove 200 Hz clock interrupt
  279. *                       -2    can't remove trap #2 handler
  280. *                       -3    can't remove both handlers
  281. *                       An error can happen if somebody corrupted the
  282. *                       XBRA vector list. This is fatal!
  283. *
  284. *  Reg:  D:01234567   A:01234567   CCR
  285. *          ***.....     **......   =D0.W
  286. *
  287. ****************************************************************************
  288.  
  289.  
  290. ****************************************************************************
  291. *
  292. *  nkc_set: set special key flags
  293. *  # G
  294. *
  295. *  This function is used to enable/disable special key handling procedures.
  296. *  The features which can be set are:
  297. *
  298. *  - direct input of ASCII codes; when switched on, pressing the Alternate
  299. *    key plus one of the numbers on the numeric keypad will start the input
  300. *    of a decimal ASCII number. The input is finished either when 3 digits
  301. *    are typed in or the Alternate key is released. NKCC will return the
  302. *    corresponding character with the entered ASCII code. This feature makes
  303. *    it possible to use the whole range of the character set (from 0 ... 255).
  304. *
  305. *  - deadkey management; when switched on, NKCC will combine some combi-
  306. *    nations of two key strokes to one character. This is used to generate
  307. *    characters with accents which are not on the keyboard. The supported
  308. *    deadkeys are:
  309. *
  310. *    ^   +   aeiou      =  âêîôû       (NKS?_D_CIRCUM)
  311. *    ~   +   nNaoAo     =  ñÑãõÃÕ      (NKS?_D_TILDE)
  312. *    '   +   eEaiou     =  éÉáíóú      (NKS?_D_AGUI)
  313. *    `   +   aeiouA     =  àèìòùÀ      (NKS?_D_GRAVE)
  314. *    ¨   +   aeiouyAOU  =  äëïöüÿÄÖÜ   (NKS?_D_UMLAUT)
  315. *    "   +   aeiouyAOU  =  äëïöüÿÄÖÜ   (NKS?_D_QUOTE)
  316. *    °   +   aA         =  åÅ          (NKS?_D_SMOERE)
  317. *    ,   +   cC         =  çÇ          (NKS?_D_CEDIL)
  318. *    /   +   oO24       =  øØ½¼        (NKS?_D_SLASH)
  319. *
  320. *    The quote character as synonym for umlaut is e.g. needed on the Dutch
  321. *    keyboard, where neither umlaut characters nor the umlaut itself are
  322. *    available.
  323. *
  324. *    Each deadkey can be enabled/disabled separately.
  325. *
  326. *  - Control key emulation: Control plus an ASCII code in the range of
  327. *    $40...$5F (characters @, A...Z, [, \, ], ^ and _) is converted
  328. *    to an ASCII code of $00...$1F.
  329. *
  330. *
  331. *  In:   D0.L           new key flags (bit set = feature on):
  332. *                       NKS?_ALTNUM       ASCII input
  333. *                       NKS?_D_...        deadkey ...
  334. *                                         (NKSf_DEADKEY: all deadkeys)
  335. *                       NKS?_CTRL         control key emulation
  336. *
  337. *  Out:  -
  338. *
  339. *  Reg:  D:01234567   A:01234567   CCR
  340. *          ***.....     **......    *
  341. *
  342. ****************************************************************************
  343.  
  344.  
  345. ****************************************************************************
  346. *
  347. *  nkc_conin: raw console character input
  348. *  # G
  349. *
  350. *  This routine replaces the Gemdos function Crawcin. However, it returns
  351. *  a WORD with the key code in normalized format rather than a LONG with
  352. *  the key code in the language dependend TOS format.
  353. *
  354. *  In:   -
  355. *
  356. *  Out:  D0.W           key code in normalized format
  357. *                       for details see nkc_tconv()
  358. *        CCR            set according content of D0.W
  359. *
  360. *  Reg:  D:01234567   A:01234567   CCR
  361. *          W**.....     **......   =D0.W
  362. *
  363. ****************************************************************************
  364.  
  365.  
  366. ****************************************************************************
  367. *
  368. *  nkc_cstat: return console character input status
  369. *  # G
  370. *
  371. *  This function checks, if a key is in the key input buffer or not.
  372. *
  373. *  In:   -
  374. *
  375. *  Out:  D0.W           flag:
  376. *                       0     no key in buffer
  377. *                       -1    at least one key in buffer
  378. *        CCR            set according content of D0.W
  379. *
  380. *  Reg:  D:01234567   A:01234567   CCR
  381. *          W**.....     **......   =D0.W
  382. *
  383. ****************************************************************************
  384.  
  385.  
  386. ****************************************************************************
  387. *
  388. *  nkc_multi: NKCC multi event
  389. *  # G U
  390. *
  391. *  nkc_multi() is a binding function to the AES multi event handler. The
  392. *  only differences are the keyboard events and the shift key state: the key
  393. *  codes are returned in normalized format (see nkc_tconv()), the shift key
  394. *  state is compatible to the NKF?_... flags. For a detailed description of
  395. *  the whole mass of parameters consult your AES manual or compiler handbook!
  396. *
  397. *  In:    4(SP).w       event mask (MU_...)
  398. *         6(SP).w       MU_BUTTON: max # of clicks to wait for
  399. *         8(SP).w       MU_BUTTON: mask of buttons to check
  400. *        10(SP).w       MU_BUTTON: button states to wait for
  401. *        12(SP).w       MU_M1: area enter/leave flag
  402. *        14(SP).w       MU_M1: x position of area
  403. *        16(SP).w       MU_M1: y position of area
  404. *        18(SP).w       MU_M1: width of area
  405. *        20(SP).w       MU_M1: height of area
  406. *        22(SP).w       MU_M2: area enter/leave flag
  407. *        24(SP).w       MU_M2: x position of area
  408. *        26(SP).w       MU_M2: y position of area
  409. *        28(SP).w       MU_M2: width of area
  410. *        30(SP).w       MU_M2: height of area
  411. *        32(SP).L       MU_MESAG: ^8 words of message buffer
  412. *        36(SP).w       MU_TIMER: low word of time to wait
  413. *        38(SP).w       MU_TIMER: high word of time to wait
  414. *        40(SP).L       MU_BUTTON/M1/M2: ^word for mouse x
  415. *        44(SP).L       MU_BUTTON/M1/M2: ^word for mouse y
  416. *        48(SP).L       MU_BUTTON/M1/M2: ^word for button state
  417. *        52(SP).L       MU_BUTTON/M1/M2: ^word for shift state
  418. *        56(SP).L       MU_KEYBD: ^word for key code in normalized format
  419. *        60(SP).L       MU_BUTTON: ^word for # of mouse clicks
  420. *
  421. *  Out:  D0.W           mask of occured events (MU_...)
  422. *
  423. *  Reg:  D:01234567   A:01234567   CCR
  424. *          W**.....     **......    *
  425. *
  426. ****************************************************************************
  427.  
  428.  
  429. ****************************************************************************
  430. *
  431. *  nkc_amulti: NKCC multi event called by Assembler  *** added by Gerd Knops
  432. *  # G U
  433. *
  434. *  See description of nkc_multi()!
  435. *
  436. *  usage: instead of    move.l   #aespb,d1
  437. *                       move  #$c8,d0
  438. *                       trap  #2
  439. *
  440. *         do            jsr   nkc_amulti
  441. *
  442. *  In:   all parameters for evnt_multi in the AES parameter arrays
  443. *
  444. *  Out:  values in intout and message buffer
  445. *
  446. *  Reg:  D:01234567   A:01234567   CCR
  447. *          ***.....     **......    *
  448. *
  449. ****************************************************************************
  450.  
  451.  
  452. ****************************************************************************
  453. *
  454. *  nkc_tconv: TOS key code converter
  455. *  # G R
  456. *
  457. *  This is the most important function within NKCC: it takes a key code
  458. *  returned by TOS and converts it to the sophisticated normalized format.
  459. *
  460. *  Note: the raw converter does no deadkey handling, ASCII input or
  461. *        Control key emulation.
  462. *
  463. *  In:   D0.L           key code in TOS format:
  464. *                                   0                    1
  465. *                       bit 31:     ignored              ignored
  466. *                       bit 30:     ignored              ignored
  467. *                       bit 29:     ignored              ignored
  468. *                       bit 28:     no CapsLock          CapsLock
  469. *                       bit 27:     no Alternate         Alternate pressed
  470. *                       bit 26:     no Control           Control pressed
  471. *                       bit 25:     no left Shift key    left Shift pressed
  472. *                       bit 24:     no right Shift key   right Shift pressed
  473. *
  474. *                       bits 23...16: scan code
  475. *                       bits 15...08: ignored
  476. *                       bits 07...00: ASCII code (or rubbish in most cases
  477. *                          when Control or Alternate is pressed ...)
  478. *
  479. *  Out:  D0.W           normalized key code:
  480. *                       bits 15...08: flags:
  481. *                                   0                    1
  482. *                       NKF?_FUNC   printable char       "function key"
  483. *                       NKF?_RESVD  ignore it            ignore it
  484. *                       NKF?_NUM    main keypad          numeric keypad
  485. *                       NKF?_CAPS   no CapsLock          CapsLock
  486. *                       NKF?_ALT    no Alternate         Alternate pressed
  487. *                       NKF?_CTRL   no Control           Control pressed
  488. *                       NKF?_LSH    no left Shift key    left Shift pressed
  489. *                       NKF?_RSH    no right Shift key   right Shift pressed
  490. *
  491. *                       bits 07...00: key code
  492. *                       function (NKF?_FUNC set):
  493. *                          < 32: special key (NK_...)
  494. *                          >=32: printable char + Control and/or Alternate
  495. *                       no function (NKF?_FUNC not set):
  496. *                          printable character (0...255!!!)
  497. *
  498. *        CCR            set according content of D0.W
  499. *
  500. *  Reg:  D:01234567   A:01234567   CCR
  501. *          U**.....     **......   =D0.W
  502. *
  503. ****************************************************************************
  504.  
  505.  
  506. ****************************************************************************
  507. *
  508. *  nkc_gconv: GEM key code converter
  509. *  # G R
  510. *
  511. *  Why a second key code converter, you ask? Well, in some cases it might
  512. *  happen that the key status byte of the original key code (with states
  513. *  of both Shift keys, Control, Alternate and CapsLock) is lost. Then
  514. *  this converter function must be called, which uses another algorithm
  515. *  to construct the normalized key code.
  516. *
  517. *  Notes:
  518. *  -  the raw converter does no deadkey handling, ASCII input or Control
  519. *     key emulation.
  520. *  -  NKCC does not use this function at all for its own purposes!
  521. *  -  some key combinations cannot be distinguished without the flag byte!
  522. *     For example, "Alternate A" and "Shift Alternate A" produce the same
  523. *     result. Whenever possible, use nkc_tconv()!
  524. *
  525. *  In:   D0.W           key code in GEM format:
  526. *                       bits 15...08: scan code
  527. *                       bits 07...00: ASCII code
  528. *
  529. *  Out:  D0.W           normalized key code (see nkc_tconv() for details)
  530. *        CCR            set according content of D0.W
  531. *
  532. *  Reg:  D:01234567   A:01234567   CCR
  533. *          U**.....     **......   =D0.W
  534. *
  535. ****************************************************************************
  536.  
  537.  
  538. ****************************************************************************
  539. *
  540. *  nkc_n2tos: convert normalized key codes back to TOS format
  541. *  # G R
  542. *
  543. *  In some cases you might have to have key codes in the original TOS format
  544. *  again, as returned by the GEMDOS functions Cconin(), Crawcin() or the BIOS
  545. *  function Bconin(). Use nkc_n2tos() to convert them. For a detailed
  546. *  description of the returned format consult the header of the function
  547. *  nkc_tconv().
  548. *
  549. *  In:   D0.W           key code in normalized format
  550. *
  551. *  Out:  D0.L           key code in TOS format:
  552. *                       bits 24...31: shift key flags
  553. *                       bits 23...16: scan code
  554. *                       bits 08...15: reserved (0)
  555. *                       bits 00...07: ASCII code
  556. *        CCR            set according content of D0.L
  557. *
  558. *  Reg:  D:01234567   A:01234567   CCR
  559. *          U**.....     **......   =D0.L
  560. *
  561. ****************************************************************************
  562.  
  563.  
  564. ****************************************************************************
  565. *
  566. *  nkc_n2gem: convert normalized key codes back to GEM format
  567. *  # G R
  568. *
  569. *  Similar to nkc_n2tos(), this function converts normalized key codes back
  570. *  to the operating system's format. The result is a key code as returned
  571. *  by the AES functions evnt_keybd() respectively evnt_multi().
  572. *
  573. *  In:   D0.W           key code in normalized format
  574. *
  575. *  Out:  D0.W           key code in GEM format:
  576. *                       bits 08...15: scan code
  577. *                       bits 00...07: ASCII code
  578. *        CCR            set according content of D0.W
  579. *
  580. *  Reg:  D:01234567   A:01234567   CCR
  581. *          U**.....     **......   =D0.W
  582. *
  583. ****************************************************************************
  584.  
  585.  
  586. ****************************************************************************
  587. *
  588. *  nkc_kstate: return state of Shift/Control/Alternate/CapsLock in
  589. *              normalized format
  590. *  # G R
  591. *
  592. *  This is a very *FAST* function which returns the state of the Shift/
  593. *  Control/Alternate and CapsLock keys in normalized format.
  594. *
  595. *  In:   -
  596. *
  597. *  Out:  D0.W           normalized key flags:
  598. *                                   0                    1
  599. *                       NKF?_CAPS   no CapsLock          CapsLock
  600. *                       NKF?_ALT    no Alternate         Alternate pressed
  601. *                       NKF?_CTRL   no Control           Control pressed
  602. *                       NKF?_LSH    no left Shift key    left Shift pressed
  603. *                       NKF?_RSH    no right Shift key   right Shift pressed
  604. *
  605. *        CCR            set according content of D0.W
  606. *
  607. *  Reg:  D:01234567   A:01234567   CCR
  608. *          w**.....     **......   =D0.W
  609. *
  610. ****************************************************************************
  611.  
  612.  
  613. ****************************************************************************
  614. *
  615. *  nkc_timer: return current value of 200 Hz system clock
  616. *  # G R
  617. *
  618. *  This is a very *FAST* function which returns the content of the 200 Hz
  619. *  system clock.
  620. *
  621. *  In:   -
  622. *
  623. *  Out:  D0.L           current 200 HZ system clock value
  624. *
  625. *  Reg:  D:01234567   A:01234567   CCR
  626. *          w**.....     **......    *
  627. *
  628. ****************************************************************************
  629.  
  630.  
  631. ****************************************************************************
  632. *
  633. *  nkc_cmp: compare two key codes
  634. *  # G R
  635. *
  636. *  nkc_cmp() compares key codes. What for, you ask? A simple "if key_code1
  637. *  = key_code2" would also do it? No! This function follows some specific
  638. *  rules, which improve the flexibility of key code comparism.
  639. *
  640. *  One of the key codes passed to nkc_cmp() is called the "reference key
  641. *  code". The other is the "test key code", which is got from nkc_conin()
  642. *  or nkc_multi(). Some flags of the reference code are treated a special
  643. *  way:
  644. *
  645. *  NKF?_IGNUM (same as NKF?_RESVD)
  646. *     if set, the numeric keypad flag doesn't matter
  647. *
  648. *  NKF?_CAPS (CapsLock)
  649. *     if set, the case of the ASCII code doesn't matter
  650. *
  651. *  NKFf_SHIFT (both Shift key flags)
  652. *     if BOTH shift flags are set, the combination of shift key flags in
  653. *     the test key code doesn't matter: only one shift flag has to be set,
  654. *     no matter which one.
  655. *
  656. *  In:   D0.W           reference key code
  657. *        D1.W           key code to test
  658. *
  659. *  Out:  D0.W           flag: 1 = key codes match
  660. *                             0 = key codes don't match
  661. *        CCR            set according content of D0.W
  662. *
  663. *  Reg:  D:01234567   A:01234567   CCR
  664. *          u**.....     **......   =D0.W
  665. *
  666. ****************************************************************************
  667.  
  668.  
  669. ****************************************************************************
  670. *
  671. *  nkc_vlink: link function to XBRA vector list
  672. *  # G U
  673. *
  674. *  This function can be used to change system vectors and let them point
  675. *  to own functions, using a standard method. The vector, which should be
  676. *  changed, is described by the contents of D0.L and D1.W. It can be
  677. *  either a standard vector number, e.g. 2 for the bus error exception
  678. *  vector, or the absolute address of the vector, e.g. $502 for the screen
  679. *  dump vector. The function to install must have the following header:
  680. *
  681. *  .dc.b    "XBRA"         magic longword
  682. *  .dc.b    "myID"         four ASCII character ID of the function
  683. *                          (NKCC uses "NKCC", for example)
  684. *  .dc.l    0              buffer for the old vector content
  685. *  function: ...           start of the function code
  686. *
  687. *  The function should end with:
  688. *
  689. *  move.l   function-4(pc),-(sp)
  690. *  rts
  691. *
  692. *
  693. *  Note: in NKXM_ADR mode, this function automatically switches (temporary)
  694. *        to Supervisor mode to prevent bus errors
  695. *
  696. *
  697. *  In:   D0.L           vector descriptor
  698. *        D1.W           mode:
  699. *                       NKXM_NUM = D0.L contains a vector number
  700. *                       NKXM_ADR = D0.L contains a vector address
  701. *        A0.L           ^function to install (NOT ^XBRA header!)
  702. *
  703. *  Out:  -4(A0.L).L     old content of vector
  704. *
  705. *  Reg:  D:01234567   A:01234567   CCR
  706. *          ***.....     **......    *
  707. *
  708. ****************************************************************************
  709.  
  710.  
  711. ****************************************************************************
  712. *
  713. *  nkc_vunlink: unlink function from XBRA vector list
  714. *  # G U
  715. *
  716. *  nkc_vunlink() removes a function which was installed using the XBRA method.
  717. *  For details see nkc_link(). If the XBRA list was corrupted, the function
  718. *  aborts with an error code. This happens, when a non-XBRA routine is
  719. *  installed on the same vector after the nkc_vlink() call of the function
  720. *  to remove.
  721. *
  722. *  Note: the function automatically switches (temporary) to Supervisor mode
  723. *        to prevent bus errors
  724. *
  725. *  In:   D0.L           vector descriptor
  726. *        D1.W           mode:
  727. *                       NKXM_NUM = D0.L contains a vector number
  728. *                       NKXM_ADR = D0.L contains a vector address
  729. *        A0.L           ^function to remove (NOT ^XBRA header!)
  730. *
  731. *  Out:  D0.W           status:
  732. *                       0 = OK
  733. *                       -1 = can't remove (XBRA list corrupted)
  734. *        CCR            set according content of D0.W
  735. *
  736. *  Reg:  D:01234567   A:01234567   CCR
  737. *          U**.....     **......   =D0.W
  738. *
  739. ****************************************************************************
  740.  
  741.  
  742. ****************************************************************************
  743. *
  744. *  nkc_toupper: convert character to upper case
  745. *  # G
  746. *
  747. *  A character is converted to upper case. Examples:
  748. *
  749. *  'a'   ->   'A'          (converted)
  750. *  '/'   ->   '/'          (unchanged; there's no upper case version for this)
  751. *  'A'   ->   'A'          (unchanged; already converted)
  752. *
  753. *
  754. *  In:   D0.B           any character
  755. *
  756. *  Out:  D0.B           character converted to upper case
  757. *
  758. *  Reg:  D:01234567   A:01234567   CCR
  759. *          U**.....     **......    *
  760. *
  761. ****************************************************************************
  762.  
  763.  
  764. ****************************************************************************
  765. *
  766. *  nkc_tolower: convert character to lower case
  767. *  # G
  768. *
  769. *  The counterpart of nkc_toupper(). A character is converted to lower case.
  770. *
  771. *  In:   D0.B           any character
  772. *
  773. *  Out:  D0.B           character converted to lower case
  774. *
  775. *  Reg:  D:01234567   A:01234567   CCR
  776. *          U**.....     **......    *
  777. *
  778. ****************************************************************************
  779.  
  780.  
  781. ****************************************************************************
  782. *                            GLOBAL BSS SECTION                            *
  783. ****************************************************************************
  784.  
  785.  
  786. *  GEM parameter arrays
  787. *  (needed if using nkc_amulti())
  788.  
  789.                .if      NKCGEM=1
  790.  
  791. nkc_contrl:     .ds.w   32                   ; control array
  792. nkc_intin:      .ds.w   32                   ; integer input array
  793. nkc_intout:     .ds.w   32                   ; integer output array
  794. nkc_adrin:      .ds.l   32                   ; address input array
  795. nkc_adrout:     .ds.l   32                   ; address output array
  796. nkc_ptsin:      .ds.l   32                   ; pointers input array
  797. nkc_ptsout:     .ds.l   32                   ; pointers output array
  798.  
  799.                .endif   ; .if NKCGEM=1
  800.  
  801.  
  802. * End Of File
  803.  
  804.